<html>
<head><meta charset="utf-8"><title>Upvar and capture difference? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Upvar.20and.20capture.20difference.3F.html">Upvar and capture difference?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="231140884"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Upvar%20and%20capture%20difference%3F/near/231140884" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Upvar.20and.20capture.20difference.3F.html#231140884">(Mar 20 2021 at 11:32)</a>:</h4>
<p>I'm confused about this code: <a href="https://github.com/rust-lang/rust/blob/eb95acea8aeaeef834214eaffb15d64095fe9271/compiler/rustc_passes/src/liveness.rs#L487-L488">https://github.com/rust-lang/rust/blob/eb95acea8aeaeef834214eaffb15d64095fe9271/compiler/rustc_passes/src/liveness.rs#L487-L488</a></p>
<p>I thought upvar == capture, but apparently not. <a href="https://rustc-dev-guide.rust-lang.org/appendix/glossary.html?highlight=upvar#glossary">The glossary</a> says about "upvar": "A variable captured by a closure from outside the closure." What is a capture then? What are the differences?</p>



<a name="231154347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Upvar%20and%20capture%20difference%3F/near/231154347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Upvar.20and.20capture.20difference.3F.html#231154347">(Mar 20 2021 at 15:58)</a>:</h4>
<p>That was added in <a href="https://github.com/rust-lang/rust/issues/78801">#78801</a> for disjoint captures, RFC 2229</p>



<a name="231154366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Upvar%20and%20capture%20difference%3F/near/231154366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Upvar.20and.20capture.20difference.3F.html#231154366">(Mar 20 2021 at 15:58)</a>:</h4>
<p>That is, an upvar might only be captured in part</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>